/**
 * Copyright (C) 2025 pony working team
 * SPDX-License-Identifier: MulanPSL-2.0
 */

/* includes (local) ----------------------------------------------------------*/
#include <bsp_lcd.h>
/* includes (standard library, system) ---------------------------------------*/
/* includes (other library) --------------------------------------------------*/
/* includes (project) --------------------------------------------------------*/
#include <hal_lcd.h>
#include <x_module.h>

/* defines -------------------------------------------------------------------*/
/* typedefs ------------------------------------------------------------------*/
/* macro ---------------------------------------------------------------------*/
/* variables (extern) --------------------------------------------------------*/
/* variables (local) ---------------------------------------------------------*/

static hal_lcd_t *lcd = NULL;

/* variables (global) --------------------------------------------------------*/
/* inlines -------------------------------------------------------------------*/
/* functions -----------------------------------------------------------------*/

static int bsp_lcd_init(void)
{
    lcd = hal_lcd_open("lcd");
    if (lcd == NULL) {
        return -1;
    }
    return 0;
}

MODULE_INIT(board, bsp_lcd_init);

int bsp_lcd_setpixel(uint32_t x, uint32_t y, uint32_t color)
{
    return hal_lcd_setpixel(lcd, x, y, color);
}

int bsp_lcd_ioctl(int cmd, uintptr_t arg)
{
    return hal_lcd_ioctl(lcd, cmd, arg);
}
